import time
from concurrent.futures import ThreadPoolExecutor

tpe = ThreadPoolExecutor(max_workers=3)


def thread_demo(times):
    time.sleep(times)
    return times


task1 = tpe.submit(thread_demo, 5)
task2 = tpe.submit(thread_demo, 2)
task3 = tpe.submit(thread_demo, 3)

# done()   return: Ture / False
print(task1.done())

# cancel()  use before submit thread pool
print(task2.cancel())

# result()  block thread ,get result after done
print(task3.result())
print('end')


